{# Template fragment for outputting a list of runs #}
{% import 'macros/helpers.twig' as helpers %}
<div class="row-fluid">
    <table class="table table-hover">
        <thead>
            <tr>
                {% if show_compare_link %}
                <th>&nbsp;</th>
                {% endif %}
                <th>
                  Method
                </th>
                <th>URL</th>
                <th>
                    {{ helpers.sort_link('Time', base_url, 'time', paging, search) }}
                </th>
                <th class="right">
                    <span class="tip" title="Wall time">
                        {{ helpers.sort_link('wt', base_url, 'wt', paging, search) }}
                    </span>
                </th>
                <th class="right">
                    <span class="tip" title="CPU time">
                        {{ helpers.sort_link('cpu', base_url, 'cpu', paging, search) }}
                    </span>
                </th>
                <th class="right">
                    <span class="tip" title="Memory Usage">
                        {{ helpers.sort_link('mu', base_url, 'mu', paging, search) }}
                    </span>
                </th>
                <th class="right">
                    <span class="tip" title="Peak Memory">
                        {{ helpers.sort_link('pmu', base_url, 'pmu', paging, search) }}
                    </span>
                </th>
                <th>
                    Ops
                </th>
            </tr>
        </thead>
        <tbody>
        {% for result in runs %}
        <tr>
            {% if show_compare_link %}
            <td>
                <a class="btn btn-small" href="{{ url('run.compare', {base: base_run.id|trim, head: result.id|trim}) }}">
                Compare
                </a>
            </td>
            {% endif %}
            <td>
              <a href="{{ url('run.view', {'id': result.id|trim }) }}">
                {{result.meta('SERVER.REQUEST_METHOD')}}
              </a>
            </td>
            <td>
                {% set addr = result.meta('SERVER.SERVER_NAME') ~ result.meta.url %}
                {{ helpers.tip_link(
                    addr,
                    50,
                    'url.view',
                    {'url': result.meta.simple_url}
                ) }}
            </td>
            <td>
              <a href="{{ url('run.view', {'id': result.id|trim }) }}">
                {{ result.date|date(date_format) }}
              </a> 
              <a href="{{ url('run.view', {'id': result.id|trim, 'filter': true }) }}">
                [filter]
              </a>
            </td>
            <td class="right">{{ result.get('main()', 'wt') |as_time }}</td>
            <td class="right">{{ result.get('main()', 'cpu') |as_time }}</td>
            <td class="right">{{ result.get('main()', 'mu') |as_bytes }}</td>
            <td class="right">{{ result.get('main()', 'pmu') |as_bytes }}</td>
            <td>
                <a href="{{ url('run.delete.form', {'id': result.id|trim }) }}">
                    <i class="icon-trash"></i>
                </a>
            </td>
        </tr>
        {% else %}
        <tr>
            <td colspan="6" class="no-results">
                Your search conditions matched no runs. Try changing you search criteria.
            </td>
        </tr>
        {% endfor %}
        </tbody>
    </table>
</div>
